#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main()
{
    FILE *stream;
    char buf[80];
    printf("open and create testfile!\n");
    if ((stream = fopen("./test_file", "w")) == NULL)
    {
        fprintf(stderr, "fopen(w) failed!\n");
    }
    printf("write string to test_file.\n");
    fputs("write string to file!", stream);
    fclose(stream);
    if ((stream = fopen("./test_file", "r")) == NULL)
    {
        fprintf(stderr, "fopen(r) failed!\n");
    }
    printf("read string from test_file!\n");
    fgets(buf, sizeof(buf), stream);
    printf("test_file content is: \"%s\"\n", buf);
    return 0;
}